﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication1.Servidor1;

namespace WebApplication1
{
    public partial class VerAsientos : System.Web.UI.Page
    {
        Service1 servidor;

        protected void Page_Load(object sender, EventArgs e)
        {
            servidor = (Service1)Session["Server"];
            if (!Page.IsPostBack)
            {
                if (Session["NombreUsuario"] == null)
                    Response.Redirect("Login.aspx");
                if (Session["Server"] != null)
                {
                    List<string> listOfNames = servidor.Obtener_Asientos(Session["NombreEmpresaUsuario"].ToString()).ToList();
                    for (int i = 0; i < listOfNames.Count(); i++)
                        listOfNames[i] = listOfNames[i].Split(';')[0] + "\t" + listOfNames[i].Split(';')[1] +
                            "\tFecha:" + listOfNames[i].Split(';')[2];
                    ListBox1.DataSource = listOfNames;
                    ListBox1.DataBind();
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            int idAsiento = Convert.ToInt32(ListBox1.SelectedValue.ToString().Split('\t')[0]);
            List<string> infoAsiento = servidor.Obtener_Info_Asiento(idAsiento, Session["NombreEmpresaUsuario"].ToString()).ToList();
            for (int i = 0; i < infoAsiento.Count(); i++)
                infoAsiento[i] = infoAsiento[i].Split(';')[0] + "\t" + infoAsiento[i].Split(';')[1] +
                    "\tFecha:" + infoAsiento[i].Split(';')[2] + "\tDebe:" + infoAsiento[i].Split(';')[3];
            ListBox2.DataSource = infoAsiento;
            ListBox2.DataBind();
        }


    }
}